package com.handydata.antifraud.web;

import com.handydata.antifraud.rule.RuleEngineInvokerFactory;
import com.handydata.common.web.AbsController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("/demo")
@RestController
public class DemoController extends AbsController {
	
	private static final Logger logger = LoggerFactory.getLogger(DemoController.class);


	@Autowired
	private RuleEngineInvokerFactory ruleEngineInvokerFactory;

	@PostMapping("/test")
	public String shriskReceive(String... a) {

		//RISK1001FLOW00410ShenZhenKeHu-antifraud_package

		List<String> list=new ArrayList<>();
		for(String b : a){
			String msg = b+"-antifraud_package.json";
			msg = msg.replace("-antifraud_package.json","/antifraud_package");
			list.add(msg);
		}
		ruleEngineInvokerFactory.refreshRulePackage(list);

		return "OK";
	}
}
